﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using He.Web.UI;

namespace He.Web.manage.weixin
{
    public partial class window_categorys : Manage
    {
        public int channel_id; //栏目种类
        public Model.channel channel;
        protected void Page_Load(object sender, EventArgs e)
        {
            siteinfo = new BLL.site_info().GetModelByLang(CurrentLang);

            if (!int.TryParse(Request.Params["channel_id"] as string, out this.channel_id))
            {
                JscriptMsg(350, 230, "错误提示", "<b>出现错误啦！</b>您要管理的类别种类不明确或参数不正确。", "back", "Error");
                return;
            }

            channel = new BLL.channel().GetModel(channel_id);

            if (!IsPostBack)
            {
                chkLoginLevel("viewCategory" + channel.id);
                ShowInfo();
            }
        }

        #region 数据绑定
        private void ShowInfo()
        {
            BLL.category bll = new BLL.category();
            rptList.DataSource = bll.GetList(0, channel_id);
            rptList.DataBind();
        }
        #endregion

        protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                Literal LitFirst = (Literal)e.Item.FindControl("LitFirst");
                HiddenField txtlayer = (HiddenField)e.Item.FindControl("txtlayer");
                string LitStyle = "<span style=width:{0}px;text-align:right;display:inline-block;>{1}{2}</span>";
                string LitImg1 = "<img src=../images/folder_open.gif align=absmiddle />";
                string LitImg2 = "<img src=../images/t.gif align=absmiddle />";

                int layer = Convert.ToInt32(txtlayer.Value);
                if (layer == 1)
                {
                    LitFirst.Text = LitImg1;
                }
                else
                {
                    LitFirst.Text = string.Format(LitStyle, layer * 18, LitImg2, LitImg1);
                }
            }
        }
    }
}